#ifndef _Q_VARS_H
#define _Q_VARS_H



enum q_vartype {VAR_BOOL = 0, VAR_INT, VAR_FLOAT, VAR_ARRAY, VAR_STRUCT, VAR_STRING};

/* variable declaration */
union q_simplevariable;
struct q_variable;

/* array */
struct q_array
{
	enum q_vartype type;
	int length;
	union q_simplevariable* elems;
};

/* char string */
struct q_string
{
	int length;
	char* chars;
};

/* structure */
struct q_struct
{
	int length;
	struct q_variable* vars;
};

/* placeholder for data */
union q_simplevariable
{
	int b;
	int i;
	double f;
	struct q_array array;
	struct q_string string;
	struct q_struct structure;
};

/* actual variable declaration */
struct q_variable
{
	enum q_vartype type;
	int constant;
	int refcount;
	union q_simplevariable data;
};

/* create functions */
struct q_variable* q_createbool(int val, int constant);
struct q_variable* q_createint(int val, int constant);
struct q_variable* q_createfloat(double val, int constant);
struct q_variable* q_createstring(const char* const val, int constant);
struct q_variable* q_createarray(int length, int constant);
struct q_variable* q_createstructure(int length, int constant);
/* copy */
struct q_variable* q_copyvariable(struct q_variable* variable, int constant);
struct q_variable* q_getref(struct q_variable* variable);
/* release functions */
void q_freevariable(struct q_variable* var);
void q_removevariable(struct q_variable* var);
#endif
